﻿/**************************************************************************
创建日期:	@NowTime@
作	  者:	@author@
邮 	  箱:	@Email@
Copyright (c)  @Copyright@

描	述：
记	录：
***************************************************************************/
using MyConsume.Models;
using System;
using System.Collections.Generic;
using System.Text;
using ZhCun.DbCore;
using ZhCun.DbCore.BuildSQLText;
using ZhCun.Utils;
using ZhCun.WebCommon.AL;
using ZhCun.WebCommon.DBModels;

namespace MyConsume.AL
{
    public static class DataRights
    {
        /// <summary>
        /// 初始化数据权限
        /// </summary>
        public static void InitDataRights()
        {
            DataRightsHelper.AddDataRights<TSysUser>(CreateUserRights);

            DataRightsHelper.AddDataRights<TAccount>(CreateUserRights);

            DataRightsHelper.AddDataRights<TConsume>(CreateUserRights);
            DataRightsHelper.AddDataRights<VConsume>(CreateUserRights);
            DataRightsHelper.AddDataRights<TConsumeItem>(CreateUserRights);
            DataRightsHelper.AddDataRights<TConsumeItem>(CreateUserRights);


            LogHelper.LogObj.Info("已初始化数据权限");
        }



        static void CreateUserRights(ISqlBuilder sql, EmDbOperation opType, TSysLoginToken loginState)
        {
            sql.AddSqlTextByGroup(@"UserId = {0}", sql.AddParam(loginState.LoginUserId));
        }

        static void LeaderIdRights(ISqlBuilder sqlBuilder, EmDbOperation opType, TSysLoginToken loginState)
        {
            // 增加操作权限
        }
    }
}
